<script lang="ts" setup>
import type { VbenFormSchema } from '@vben/common-ui';

import { computed } from 'vue';
import SloganIcon from './icons/slogan.vue';

import { AuthenticationLogin, z } from '@vben/common-ui';
import { useAuthStore } from '#/store';

defineOptions({ name: 'Login' });

const authStore = useAuthStore();

const formSchema = computed((): VbenFormSchema[] => {
  return [
    {
      component: 'VbenInput',
      componentProps: {
        placeholder: '请输入用户名',
      },
      fieldName: 'userName',
      label: '用户名',
      rules: z.string().min(1, { message:'请输入用户名' }),
    },
    {
      component: 'VbenInputPassword',
      componentProps: {
        placeholder: '请输入密码',
      },
      fieldName: 'password',
      label: '密码',
      rules: z.string().min(1, { message: "请输入密码" }),
    }
  ];
});

</script>

<template>
  <div class="login-container">
    <div class="login-content">
      <div class="form-container">
        <div class="login-form">
          <div class="left-image">
            <SloganIcon  class="animate-float h-84 w-3/5" />
          </div>
          <div class="right-form">
            <AuthenticationLogin
            :form-schema="formSchema"
            :loading="authStore.loginLoading"
            @submit="authStore.authLogin"
          />
          </div>
        </div>
      </div>
    </div>
    
  </div>
</template>
<style lang="less">
.login-container {
  width:100%;
  height:100vh;
  background:url(../../../assets/login-bg.png) no-repeat;
  background-size: 100%;
  position: relative;
}
.login-content {
  padding: 40px 60px;
  min-height: 100vh; 
}
.form-container {
    max-width: 1000px;
    margin: 0 auto;
    box-shadow: 0 4px 8px 1px #0003;
    position: fixed;
    top: 50%;
    left: 50%;
    width: 92%;
    transform: translate(-50%,-50%);
    height: auto;
}
.login-form {
  width: 100%;
  background: #eee;
  display: flex;
  flex-direction: row;
  height: 100%;
}
.left-image {
  background-color: #0198cd;
  flex:1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.right-form {
  width: 45%;
  padding:5vw 30px;
  background: #fff;
}
</style>
